from google.appengine.ext import webapp
from google.appengine.api import users

class BaseAction(webapp.RequestHandler):
    dict_data = None
    
    def __init__(self):
        self.dict_data = {
            "user_status" : user_wrapper(),
        }
    
    def viewdata(self, key, value):
        self.dict_data[key] = value
    
    def get_viewdata(self):
        #self.viewdata( "user_status", user_wrapper() )
        return self.dict_data

class user_wrapper(object):
    user_name = None
    entrance_status = None
    entrance_url = None
    
    def __init__( self ):
        user = users.get_current_user()
        if user:
            self.user_name = str( user )
            self.entrance_status = "Logout"
            self.entrance_url = users.create_logout_url( "/" )
        else:
            self.user_name = 'Guest'
            self.entrance_status = 'Login'
            self.entrance_url = users.create_login_url( "/" )